﻿#region 命名空间

using System;
using System.Collections;
using System.Data;
using System.Web;
using System.Web.Services;
using System.Web.Services.Protocols;

#endregion

namespace WinnerCMS.WebUI
{
    /// <summary>
    ///     $codebehindclassname$ 的摘要说明
    /// </summary>
    [WebService(Namespace = "http://tempuri.org/"), WebServiceBinding(ConformsTo = WsiProfiles.BasicProfile1_1)]
    public class AdsClick : IHttpHandler
    {
        public void ProcessRequest(HttpContext context)
        {
            if (context.Request["ID"] == null || context.Request["Go"] == null)
            {
                return;
            }
            var C = context.Request.Cookies["WinnerCMS.com_Ad"];
            if (C == null)
            {
                var ADCookie = new HttpCookie("WinnerCMS.com_Ad");
                ADCookie.Values.Add("AdID", context.Request["ID"]);
                ADCookie.Expires.AddHours(24);
                context.Response.Cookies.Add(ADCookie);
                new BLL.AdsManage().Click(context.Request["ID"]);
            }
            else
            {
                if (C.Values["AdID"] != context.Request["ID"])
                {
                    new BLL.AdsManage().Click(context.Request["ID"]);
                }
            }
            context.Response.Redirect(context.Request["Go"]);
        }


        public bool IsReusable
        {
            get { return false; }
        }
    }
}